package com.huiyuan.controller;


import com.huiyuan.common.Page;
import com.huiyuan.common.Result;

import com.huiyuan.common.Bike;
import com.huiyuan.service.BikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;




/**
 * @author huiyuan080
 * @data 2023/5/2
 * @apiNote
 */
@RestController
@RequestMapping("/bicycle-service/bicycle")
public class BikeController {

    @Autowired
    private BikeService bikeService;

    /**
     * 分页展示车辆信息
     *
     * @param page
     * @return
     */
    @PostMapping("/getBicycle")
    public Result getBicycle(@RequestBody Page page) {
        return new Result(bikeService.getBicycle(page));
    }

    /**
     * 修改车辆的使用情况
     *
     * @param bicycleId
     * @return
     */
    @GetMapping("addUse/{bicycleId}")
    public Result addUse(@PathVariable Integer bicycleId) {
        bikeService.addUse(bicycleId);
        return new Result();
    }

    /**
     * 车辆的状态
     */
    @GetMapping("isNull/{bicycleId}")
    public Bike isNull(@PathVariable Integer bicycleId) {
       Bike bike =  bikeService.isNull(bicycleId);
        return bike;
    }
}
